import java.util.Scanner;

public class school_tree {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int l = sc.nextInt();
        int m = sc.nextInt();
        int count = 0;
        int[] arr = new int[l+1];
        for(int i = 0;i<m;i++){
            int a = sc.nextInt();
            int b = sc.nextInt();
            for (int j = a; j <= b; j++) {
                if(j<=l){
                    arr[j]=1;
                }
            }
        }
        for (int i = 0; i <=l ; i++) {
            if(arr[i]!=1){
                count++;
            }
        }
        System.out.println(count);
    }
}
